/*function ListNode(x){
    this.val = x;
    this.next = null;
}*/
function ReverseList(pHead) {
  // write code here
  if (pHead != null) {
    var cur = pHead
    var pre = null
    var tmp = null
    while (cur != null) {
      tmp = cur.next
      cur.next = pre
      pre = cur
      cur = tmp
    }
    return pre
  } else {
    return null
  }
}
